package com.letwal.cmcvnd.earn.todayEarn.adapter

import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.letwal.cmcvnd.R
import com.letwal.cmcvnd.adata.home.getTransferInExtractList.RevDataGetTransferInExtractList
import com.letwal.cmcvnd.extend.toFinanceString

class TotalEarnDetailWithdrawalTimesAdapter(private val dataList: List<RevDataGetTransferInExtractList>) :
    RecyclerView.Adapter<TotalEarnDetailWithdrawalTimesAdapter.ViewHolder>() {

    inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        var textAdapterTotalEarnDetailWithdrawalTimesDateValue: TextView =
            view.findViewById(R.id.textAdapterTotalEarnDetailWithdrawalTimesDateValue)
        var textAdapterTotalEarnDetailWithdrawalTimesEarnAmountValue: TextView =
            view.findViewById(R.id.textAdapterTotalEarnDetailWithdrawalTimesEarnAmountValue)
    }

    override fun onCreateViewHolder(
        parent: ViewGroup,
        viewType: Int,
    ): ViewHolder {
        val view = LayoutInflater.from(parent.context)
            .inflate(R.layout.view_adpter_total_earn_detail_withdrawal_times, parent, false)
        return ViewHolder(view)
    }

    @SuppressLint("SetTextI18n")
    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val data: RevDataGetTransferInExtractList = dataList[position]
        holder.textAdapterTotalEarnDetailWithdrawalTimesDateValue.text = data.createTime
        try {
            holder.textAdapterTotalEarnDetailWithdrawalTimesEarnAmountValue.text =
                data.amount.toFinanceString() + " USDT"
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    override fun getItemCount(): Int {
        return dataList.size
    }
}